var t = require;
var e = module;
var o = exports;
var n =
        (this && this.__extends) ||
        (function () {
            var t = function (e, o) {
                return (t =
                    Object.setPrototypeOf ||
                    ({__proto__: []} instanceof Array &&
                        function (t, e) {
                            t.__proto__ = e;
                        }) ||
                    function (t, e) {
                        for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                    })(e, o);
            };
            return function (e, o) {
                function n() {
                    this.constructor = e;
                }
                t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
            };
        })(),
    r =
        (this && this.__decorate) ||
        function (t, e, o, n) {
            var r,
                a = arguments.length,
                i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
            return a > 3 && i && Object.defineProperty(e, o, i), i;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("fsm"),
    i = t("Sounds"),
    s = t("fightManager"),
    c = t("Load"),
    l = t("flyBoxSingle"),
    u = cc._decorator,
    p = u.ccclass,
    f = u.property,
    d = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.box = null), (e.passThroughCount = 0), e;
        }
        return (
            n(e, t),
            (e.prototype.onEnable = function () {
                var t = this.data.Offset[0] * this.body.direction.value * -1,
                    e = this.data.Offset[1];
                (this.node.x = this.body.node.x + t), (this.node.y = this.body.node.y + e);
                var o = this.body.direction.value > 0 ? 180 : 0,
                    n = (o = this.data.jiaodu + o) * (Math.PI / 180),
                    r = Math.cos(n) * this.data.speed,
                    s = Math.sin(n) * this.data.speed;
                if (((this.speed = cc.v2(r, s)), 1 == this.data.attackTeamType))
                    this.body.is_player() ? (this.node.group = "A_self") : (this.node.group = "A_enemy"),
                        a.changeState(this, l.default);
                else {
                    if (2 != this.data.attackTeamType)
                        throw Error("未知 attackTargetType：" + this.data.attackTeamType);
                    this.body.is_player() ? (this.node.group = "A_enemy") : (this.node.group = "A_self"),
                        a.changeState(this, l.default);
                }
                if (((this.box.size = cc.size(this.data.BoxSize[0], this.data.BoxSize[1])), "-1" != this.data.effect)) {
                    var u = new cc.Node("effect");
                    u.parent = this.node;
                    var p = u.addComponent(sp.Skeleton);
                    (p.skeletonData = c.default.skeletonDatas[this.data.effect]),
                        (p.premultipliedAlpha = !1),
                        (p.useTint = !0),
                        p.setAnimation(0, "animation", !0);
                    var f = this.body.direction.value;
                    (u.x = this.data.effectOffset[0] * f),
                        (u.y = this.data.effectOffset[1]),
                        (u.scale = this.data.fangda),
                        (u.scaleX *= f);
                }
                this.data.toneId && i.Sounds.playFX(this.data.toneId);
            }),
            (e.prototype.isDestory = function () {
                if (0 == this.data.passThroughType) return !0;
                if (1 == this.data.passThroughType) {
                    if ((this.passThroughCount++, this.passThroughCount > this.data.passnumber)) return !0;
                } else if (
                    2 == this.data.passThroughType &&
                    (this.passThroughCount++, this.passThroughCount > this.data.passnumber)
                )
                    return !0;
            }),
            (e.prototype.update = function (t) {
                (t *= s.default.inst.speed.value),
                    (this.node.x += this.speed.x * t),
                    (this.node.y += this.speed.y * t),
                    this.state.onUpdate(t);
            }),
            r([f(cc.BoxCollider)], e.prototype, "box", void 0),
            (e = r([p], e))
        );
    })(cc.Component);
o.default = d;
